/***************************************************************************
 * *   File name: ClassFactory.cpp
 * *    Describe: 实现类的注册
 * *  Created on: 2016-8-6
 * *      Author: dengxiudong
 * ************************************************************************/ 
#include "ClassFactory.h"

#include <loong/Logger.h>
#include <string>

uint16_t ObjBase::getCmd()
{
	if (m_cmd == 0)
	{
		INFO("Cmd is not define");
	}
	return m_cmd;
}

std::map<uint16_t, ObjBase*> ClassFactory::m_objMap;
ClassFactory::ClassFactory()
{
}

ClassFactory::~ClassFactory()
{
}

ObjBase * ClassFactory::getObject(uint16_t cmd)
{
	auto obj = m_objMap.find(cmd);
	if (obj != m_objMap.end())
	{
		return obj->second;
	}
	else
	{
		return nullptr;
	}
}

void ClassFactory::registerClass(ObjBase * obj)
{
	m_objMap[obj->getCmd()] = obj;
}


